#ifndef __STATUS_H__
#define __STATUS_H__

#include "bsp_distance.h"
#include "bsp_motor.h"
#include "bsp_psw.h"
#include "Arduino.h"
#include <HardwareSerial.h>
#include <stdint.h>

extern uint8_t flag_OnStage;
extern uint8_t flag_UnderStage;
extern uint8_t flag_object;
extern uint8_t flag_backStage;

typedef enum e_status
{
  onStage,
  fl_out = 0b0001,
  fr_out = 0b0010,
  bl_out = 0b0100,
  br_out = 0b1000,

  underStage,
  f_toStage = 0b0001,
  b_toStage = 0b0010,
  l_toStage = 0b0100,
  r_toStage = 0b1000,
  corner_fl = 0b0001 << 4,
  corner_fr = 0b0010 << 4,
  corner_bl = 0b0100 << 4,
  corner_br = 0b1000 << 4,
  NONE_toStage = 0,

  object,
  f_object = 0b0001,
  b_object = 0b0010,
  l_object = 0b0100,
  r_object = 0b1000,

  _status,
  f_stage = 0b0001 << 4,
  b_stage = 0b0010 << 4,
  l_stage = 0b0100 << 4,
  r_stage = 0b1000 << 4,
  f_frame = 0b0001,
  b_frame = 0b0010,
  l_frame = 0b0100,
  r_frame = 0b1000

} e_status;

#define UP 0
#define DOWN 1
#define DISTANCE 40


#define IF(X, Y) ((X & (1 << (Y - 1))) != 0)

uint8_t OU_verdict(void);
uint8_t isOnStage(void);
uint8_t isUnderStage(void);
uint8_t isObject(void);
uint8_t pswDetect(uint8_t upOrDown);
uint8_t distanceDetect(int range);

#endif
